
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>

#include <ListBoxPeople.h>
#include <PeopleData.h>

#include <InchFormat.h>
#include <CascadeFormat.h>

#include <RadioButton.h>
#include <Button.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(ListBoxPeople)
{
	CascadeFormat cascadeFormat;
	InchFormat inchFormat;
	ostringstream ostrCommon;
	ListBoxPeople boxCommon;

	SETUP()
	{
		PeopleData ChangSan("San Chang",Length(61,INCH));
                PeopleData LiSi("Si Li",Length(67,INCH));
		PeopleData WangWu("Wu Wang",Length(93,INCH));

		PeopleData QinHui("Hui Qin",Length(54,INCH));
                PeopleData YueFei("Fei Yue",Length(86,INCH));
		PeopleData ZhaoGou("Gou Zhao",Length(64,INCH));

		boxCommon.addPeople(ChangSan);
		boxCommon.addPeople(LiSi);
		boxCommon.addPeople(WangWu);

		boxCommon.addPeople(QinHui);
		boxCommon.addPeople(YueFei);
		boxCommon.addPeople(ZhaoGou);
	}

	TEST(should be able to output data with requirement:default format)
	{
		FormatRadioButton radioButton(cascadeFormat);
		PeopleButton button(radioButton);

		button.setPeopleList(ostrCommon, boxCommon);
		button.onClick();
		ASSERT_EQ(ostrCommon.str(), string("San Chang\t5 FEET 1 INCH\nSi Li\t5 FEET 7 INCH\nWu Wang\t7 FEET 9 INCH"));		
	}

	TEST(should be able to output data with requirement:default format)
	{
		FormatRadioButton radioButton(cascadeFormat);
		PeopleButton button(radioButton);

		button.setPeopleList(ostrCommon, boxCommon);
		button.onClick();
		ASSERT_EQ(ostrCommon.str(), string("Hui Qin\t4 FEET 6 INCH\nFei Yue\t7 FEET 2 INCH\nGou Zhao\t5 FEET 4 INCH"));		
	}

	TEST(should be able to output data with requirement:select INCH format)
	{
		FormatRadioButton radioButton(cascadeFormat);
		PeopleButton button(radioButton);

		radioButton.onSelected(inchFormat);
		button.setPeopleList(ostrCommon, boxCommon);
		button.onClick();
		ASSERT_EQ(ostrCommon.str(), string("San Chang\t61 INCH\nSi Li\t67 INCH\nWu Wang\t93 INCH"));
	}

	TEST(should be able to output data with requirement:select INCH format)
	{
		FormatRadioButton radioButton(cascadeFormat);
		PeopleButton button(radioButton);

		radioButton.onSelected(inchFormat);
		button.setPeopleList(ostrCommon, boxCommon);
		button.onClick();
		ASSERT_EQ(ostrCommon.str(), string("Hui Qin\t54 INCH\nFei Yue\t86 INCH\nGou Zhao\t64 INCH"));	
	}

};
